package com.test.demo02;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.support.ScheduledMethodRunnable;
import org.springframework.stereotype.Component;


@Component
public class ScheduleTask {

    /**
     * logger.
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleTask.class);

    /**
     * 默认线程池，1个线程
     */
    //固定2秒执行一次该方法
    @Scheduled(fixedRate = 6000000)
    public void testScheduleTask() {
        try{
            LOGGER.info("testScheduleTask");
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}